//商品相关接口
import request from "@/utils/request.ts";
import type { CategoryResponseData, AttrResponseData, AttrObj } from "./type";

// 品牌接口

enum API {
  // 商品分类接口 :
  // GET
  category1 = "/admin/product/get/category1",
  // 获取一级分类
  // GET
  category2 = "/admin/product/get/category2",
  // 获取二级分类
  // GET
  category3 = "/admin/product/get/category3",
  // 获取三级分类
  // GET
  getCategory1 = "/admin/product/getCategory1",
  // getCategory1
  // GET
  getCategory2 = "/admin/product/getCategory2",
  // getCategory2
  // GET
  getCategory3 = "/admin/product/getCategory3",
  // getCategory3
  // POST
  findBaseCategory3ByCategory3IdList = "/admin/product/inner/findBaseCategory3ByCategory3IdList",
  // findBaseCategory3ByCategory3IdList
  // DELETE
  removeCategory1 = "/admin/product/removeCategory1",
  // 删除一级分类
  // DELETE
  removeCategory2 = "/admin/product/removeCategory2",
  // 删除二级分类
  // DELETE
  removeCategory3 = "/admin/product/removeCategory3",
  // 删除三级分类
  // POST
  saveCategory1 = "/admin/product/saveCategory1",
  // 新增一级分类
  // POST
  saveCategory2 = "/admin/product/saveCategory2",
  // 新增二级分类
  // POST
  saveCategory3 = "/admin/product/saveCategory3",
  // 新增三级分类
  // PUT
  updateeCategory1 = "/admin/product/updateeCategory1",
  // 修改一级分类
  // PUT
  updateeCategory2 = "/admin/product/updateeCategory2",
  // 修改二级分类
  // PUT
  updateeCategory3 = "/admin/product/updateeCategory3",
  // 修改三级分类

  // GET
  attrInfoList = "/admin/product/attrInfoList",
  // attrInfoList

  // DELETE
  deleteAttr = "/admin/product/deleteAttr",
  // deleteAttr

  // GET
  getAttrValueList = "/admin/product/getAttrValueList",
  // getAttrValueList

  // POST
  saveAttrInfo = "/admin/product/saveAttrInfo",
}

export const reqcategory1 = (id: number) =>
  request.get<any, any>(API.category1 + `/${id}`);
export const reqcategory2 = (id: number) =>
  request.get<any, any>(API.category2 + `/${id}`);
export const reqcategory3 = (id: number) =>
  request.get<any, any>(API.category3 + `/${id}`);

export const reqgetCategory1 = () =>
  request.get<any, CategoryResponseData>(API.getCategory1);
export const reqgetCategory2 = (c1id: number) =>
  request.get<any, CategoryResponseData>(API.getCategory2 + `/${c1id}`);
export const reqgetCategory3 = (c1id: number) =>
  request.get<any, CategoryResponseData>(API.getCategory3 + `/${c1id}`);

export const reqfindBaseCategory3ByCategory3IdList = () =>
  request.post<any, any>(API.findBaseCategory3ByCategory3IdList);

export const reqremoveCategory1 = (id: number) =>
  request.delete<any, any>(API.removeCategory1 + `/${id}`);
export const reqremoveCategory2 = (id: number) =>
  request.delete<any, any>(API.removeCategory2 + `/${id}`);
export const reqremoveCategory3 = (id: number) =>
  request.delete<any, any>(API.removeCategory3 + `/${id}`);

export const reqsaveCategory1 = () => request.post<any, any>(API.saveCategory1);
export const reqsaveCategory2 = () => request.post<any, any>(API.saveCategory2);
export const reqsaveCategory3 = () => request.post<any, any>(API.saveCategory3);

export const requpdateeCategory1 = () =>
  request.put<any, any>(API.updateeCategory1);
export const requpdateeCategory2 = () =>
  request.put<any, any>(API.updateeCategory2);
export const requpdateeCategory3 = () =>
  request.put<any, any>(API.updateeCategory3);

export const reqattrInfoList = (
  category1Id: number,
  category2Id: number,
  category3Id: number,
) =>
  request.get<any, AttrResponseData>(
    API.attrInfoList + `/${category1Id}/${category2Id}/${category3Id}`,
  );
export const reqdeleteAttr = (attrId: number) =>
  request.delete<any, any>(API.deleteAttr + `/${attrId}`);
export const reqgetAttrValueList = (attrId: number) =>
  request.get<any, any>(API.getAttrValueList + `/${attrId}`);
export const reqsaveAttrInfo = (data: AttrObj) =>
  request.post<any, any>(API.saveAttrInfo, data);
